package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.CountryDAO;
import com.pojo.Country;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: T-bao
 * @Date: 2021-4-14 9:22
 * @Description:  国籍Service
 */
@Service
public class CountryService extends ServiceImpl<CountryDAO, Country> {

    @Autowired
    private CountryDAO countryDAO;

    public IPage<Country> selectCountry(String name, int page, int limit){
        Page p = new Page(page,limit);
        QueryWrapper query = new QueryWrapper() ;
        if(StringUtil.isNotNull(name)) {
            query.like("zh_name" , name) ;
        }
        query.eq("is_show",1);

        IPage<Country> iPage = countryDAO.selectPage(p,query);
        return iPage;
    }

    public List<Country> selectGuojia(){
        return countryDAO.selectList(new QueryWrapper<Country>().eq("is_show",1));
    }
}
